package com.chinawlx.wlxteacher.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chinawlx.wlxteacher.R;
import com.chinawlx.wlxteacher.ui.adapter.WLXUnReadAdapter;
import com.chinawlx.wlxteacher.utils.WLXGreenDaoUtil;
import com.chinawlx.wlxteacher.utils.WLXLogUtil;
import com.chinawlx.wlxteacher.utils.WLXTeacherConstant;
import com.chinawlx.wlxteacher.wlx_student;
import com.chinawlx.wlxteacher.wlx_studentDao;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 未阅人员界面
 * Created by wlx on 16/10/12.
 */

public class WLXUnReadNumberActivity extends WLXBaseActivity {
    @BindView(R.id.recylerview)
    RecyclerView mRecyclerView;
    private List<wlx_student> wlxStudents;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_unread);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        initData();
        initView();
    }

    private void initView() {
        mRecyclerView.setLayoutManager(new GridLayoutManager(this, 4));
        mRecyclerView.setAdapter(new WLXUnReadAdapter(this, wlxStudents));
        WLXLogUtil.printE("----wlxStudents----" + wlxStudents.size());

    }

    private void initData() {
        wlxStudents = new ArrayList<>();
        Intent intent = getIntent();
        String[] familyUserIds = intent.getStringArrayExtra(WLXTeacherConstant
                .FAMILY_USER_IDS);
        for (String familyUserId : familyUserIds) {
            wlx_student student = WLXGreenDaoUtil.getStudentDao().queryBuilder().where
                    (wlx_studentDao.Properties.Family_user_id.eq(familyUserId)).unique();
            wlxStudents.add(student);

        }
    }
    @OnClick({R.id.iv_back_unread})
    public void onClick(View v){
        switch (v.getId()){
            case R.id.iv_back_unread:
                finish();
                break;
        }
    }
}
